Represents a job that can be executed by a store
Namespace: Microsoft.LearningComponents.Storage
Assembly: Microsoft.LearningComponents.Storage.dll
| C# |
|
public class LearningStoreJob |
| Name | Description | |
| Ð | AddItem (string, IDictionary<string,object>) | Add a new item |
| Ð | AddItem (string, IDictionary<string,object>, bool) | Add a new item to a store. |
| Ð | AddOrUpdateItem (string, IDictionary<string,object>, IDictionary<string,object>) | Add an item, or update the item properties if the item already exists |
| Ð | AddOrUpdateItem (string, IDictionary<string,object>, IDictionary<string,object>, IDictionary<string,object>) | Add an item, or update the item properties if the item already exists |
| Ð | AddOrUpdateItem (string, IDictionary<string,object>, IDictionary<string,object>, IDictionary<string,object>, bool) | Add an item, or update the item properties if the item already exists |
| Ð | DeleteItem | Delete an item |
| Ð | DemandRight (string) | Demand a right. When the job is executed, the job will be aborted unless the current user has the specified right. |
| Ð | DemandRight (string, IDictionary<string,object>) | Demand a right. When the job is executed, the job will be aborted unless the current user has the specified right. |
| Ð | DisableFollowingSecurityChecks | Disable security checks for the operations added to the job after this call. |
| Ð | EnableFollowingSecurityChecks | Enable security checks for the operations added to the job after this call. |
| Ð | Execute () | Execute the commands in the job |
| Ð | Execute<T> () | Execute the commands in the job. |
| Ð | PerformQuery | Perform a query |
| Ð | UpdateItem | Update properties on an item |
A job is a collection of operations that can be performed on a store. All of the operations are executed as a batch, and if any of the operations fail, then the entire job fails. To create and execute a job, perform the following steps:
Here's some example code that adds a new user to a store:
| C# |
// Create the job
LearningStoreJob job = store.CreateJob();
// Add the "add" operation
Dictionary<string,object> propertyValues = new Dictionary<string,object>();
propertyValues["Name"] = "John Doe";
propertyValues["Key"] = "Company\JohnDoe";
job.AddItem("UserItem", propertyValues);
// Execute the job
job.Execute();
|
| C# |
// Create the job
LearningStoreJob job = store.CreateJob();
// Add the first "add" operation that adds the user
Dictionary<string,object> propertyValues = new Dictionary<string,object>();
propertyValues["Name"] = "John Doe";
propertyValues["Key"] = "Company\JohnDoe";
LearningStoreItemIdentifier newUserId = job.AddItem("UserItem", propertyValues);
// Add the second "add" operation that adds the global objective
propertyValues = new Dictionary<string,object>();
propertyValues["Key"] = "MyGlobalObjective";
propertyValues["Description"] = "MyGlobalObjective Description";
LearningStoreItemIdentifier newGlobalObjectiveId = job.AddItem("GlobalObjectiveItem", propertyValues);
// Add the third "add operation" that adds the learner global objective
propertyValues = new Dictionary<string,object>();
propertyValues["LearnerId"] = newUserId;
propertyValues["GlobalObjectiveId"] = newGlobalObjectiveId;
job.AddItem("LearnerGlobalObjectiveItem", propertyValues);
// Execute the job, which adds all the items
job.Execute();
|
| C# |
// Create the job
LearningStoreJob job = store.CreateJob();
// Add the first "add" operation that adds the user
Dictionary<string,object> propertyValues = new Dictionary<string,object>();
propertyValues["Name"] = "John Doe";
propertyValues["Key"] = "Company\JohnDoe";
LearningStoreItemIdentifier newUserId = job.AddItem("UserItem", propertyValues, true); // passing true forces the operation to return the Id of the new item in the store in the results
// Add the second "add" operation that adds the global objective
propertyValues = new Dictionary<string,object>();
propertyValues["Key"] = "MyGlobalObjective";
propertyValues["Description"] = "MyGlobalObjective Description";
LearningStoreItemIdentifier newGlobalObjectiveId = job.AddItem("GlobalObjectiveItem", propertyValues);
// Add the third "add operation" that adds the learner global objective
propertyValues = new Dictionary<string,object>();
propertyValues["LearnerId"] = newUserId;
propertyValues["GlobalObjectiveId"] = newGlobalObjectiveId;
job.AddItem("LearnerGlobalObjectiveItem", propertyValues, true); // passing true forces the operation to return the Id of the new item in the store in the results
// Execute the job, which adds all the items
ReadOnlyCollection<object> results = job.Execute();
|
See the Execute method documentation for more information about executing jobs, including information about how jobs interact with transactions.